#include "AiTool.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QTextEdit>
#include "TextCapture.h"
#include <QDebug>


AiTool::AiTool(QWidget *parent)
    : QWidget(parent)
{
    // 设置无边框
    this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint);
    // 设置鼠标悬停事件
    setAttribute(Qt::WA_Hover); 
    // 初始化UI
    initUI();
}

AiTool::~AiTool()
{

}

void AiTool::initUI(){
    // 设置宽高
    this->setFixedSize(800, 1200);
    // 设置背景色
    this->setStyleSheet("background-color: rgb(222, 219, 219);");
    // 设置布局
    // 纵向布局
    QVBoxLayout *mainLayout1 = new QVBoxLayout(this);
    titleBar = new AiTitleBar(this);
    mainLayout1->setContentsMargins(0, 0, 0, 0);
    mainLayout1->setSpacing(0);
    mainLayout1->addWidget(titleBar);

    QVBoxLayout *mainLayout = new QVBoxLayout(this);
    mainLayout->setContentsMargins(10, 0, 10, 10);
    mainLayout->setSpacing(0);
    
    aiDialog = new AiDialog(this);
    aiDialog->setFixedHeight(890);
    // aiDialog->setWidget(new Widget());

    mainLayout->addWidget(aiDialog);

    customToolbar = new ICustomToolbar(this);
    mainLayout->addWidget(customToolbar);

    textInput = new AiTextInput(this);
    mainLayout->addWidget(textInput);
    mainLayout1->addLayout(mainLayout);

    setLayout(mainLayout1);

    
    // 初始化文字捕获
    TextCapture* capture = new TextCapture(this);
    connect(capture, &TextCapture::textCaptured, [this](const QString& text) {
        this->textInput->setEditText(text);
    });
}
